package src;

import java.awt.Color;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;

import com.lyfam.game.behaviosr.steering.FleeingBehavior;
import com.lyfam.game.behaviosr.steering.ISteeringBehavior;
import com.lyfam.game.behaviosr.steering.SeekingBehavior;
import com.lyfam.game.behaviosr.steering.SteeringEngine;
import com.lyfam.game.behaviosr.steering.WanderingBehavior;
import com.lyfam.game.entity.Obstacle;
import com.lyfam.game.entity.Vehicle;
import com.lyfam.game.geometry.Vector2D;

import processing.core.PApplet;

@SuppressWarnings("serial")
public class SteeringTest1 extends PApplet
{
	private static final int NUM_VEHICLES = 1;
	List<Vehicle> vehicles = new ArrayList<Vehicle>(10);
	ISteeringBehavior seek;
	Vector2D target = new Vector2D(200, 200);
	
    public void setup()
    {
    	
        setSize(400, 400);
        colorMode(RGB, 100);

        noLoop();
    }
    
    public void draw()
    {
    	background(100);
    	Vector2D v = new Vector2D(width/2, height/2);
		Vehicle veh = new Vehicle(v, new Vector2D(2, 1), 5f, 0.25f);
		veh.setSize(8);
		veh.render(g);
		
		noFill();
		float theta1 = PApplet.radians(360) * random(-1, 0);
		float wanderRadius = 20;
		Vector2D wanderTarget = new Vector2D(
				(float) Math.cos(theta1) * wanderRadius, (float) Math.sin(theta1)
						* wanderRadius);
		wanderTarget.add(new Vector2D(random(-1,1) * 80, random(-1,1)
				* 80));
		wanderTarget.normalize();
		wanderTarget.mult(wanderRadius);
		
		float line_length = 25;
		pushMatrix();
		float theta = veh.getVelocity().heading2D();
		translate(veh.getPosition().getX(), veh.getPosition().getY());
		rotate(theta);
		line(0, 0, line_length*2, 0);
		line(0, 0, 0, line_length);
		popMatrix();
		
		pushMatrix();
		translate(veh.getPosition().getX(), veh.getPosition().getY());
		rotate(theta);
		translate(50, 0);
		line(0, 0, wanderTarget.getX(), wanderTarget.getY());
		ellipse(0, 0, wanderTarget.getLength()*2, wanderTarget.getLength()*2);
		popMatrix();
    }

	@Override
	public void mouseClicked(MouseEvent arg0)
	{
		target.setX(arg0.getX());
		target.setY(arg0.getY());
	}
    
}
